package org.mesh4j.sync.adapters.feed;

import java.util.Vector;

import org.mesh4j.sync.model.Item;
import org.mesh4j.sync.validations.Guard;

public class Feed {

	// MODEL VARIABLES
	private Vector<Item> feedItems = new Vector<Item>();
	private String payload;
		
	// BUSINES METHODS
	public Feed(){
		super();
	}
	
	public Feed(Vector<Item> items){
		super();
		Guard.argumentNotNull(items, "items");
		this.feedItems = items;
	}

	public Feed addItem(Item item) {
		this.feedItems.addElement(item);
		return this;
		
	}

	public Feed deleteItem(Item item) {
		this.feedItems.removeElement(item);
		return this;
	}

	public Vector<Item> getItems() {
		return this.feedItems;
	}

	public String getPayload() {
		return payload;
	}
	public void setPayload(String payload) {
		this.payload = payload;		
	}

	public Item getItemBySyncId(String syncId) {
		for (Item item : this.feedItems) {
			if(item.getSyncId().equals(syncId)){
				return item;
			}
		}
		return null;
	}

}
